/* A Bison parser, made by GNU Bison 3.7.4.  */

/* Bison interface for Yacc-like parsers in C

   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
   Inc.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

/* As a special exception, you may create a larger work that contains
   part or all of the Bison parser skeleton and distribute that work
   under terms of your choice, so long as that work isn't itself a
   parser generator using the skeleton or a modified version thereof
   as a parser skeleton.  Alternatively, if you modify or redistribute
   the parser skeleton itself, you may (at your option) remove this
   special exception, which will cause the skeleton and the resulting
   Bison output files to be licensed under the GNU General Public
   License without this special exception.

   This special exception was added by the Free Software Foundation in
   version 2.2 of Bison.  */

/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
   especially those whose name start with YY_ or yy_.  They are
   private implementation details that can be changed or removed.  */

#ifndef YY_MENT_BISON_PARSER_HPP_INCLUDED
# define YY_MENT_BISON_PARSER_HPP_INCLUDED
/* Debug traces.  */
#ifndef MENT_DEBUG
# if defined YYDEBUG
#if YYDEBUG
#   define MENT_DEBUG 1
#  else
#   define MENT_DEBUG 0
#  endif
# else /* ! defined YYDEBUG */
#  define MENT_DEBUG 0
# endif /* ! defined YYDEBUG */
#endif  /* ! defined MENT_DEBUG */
#if MENT_DEBUG
extern int ment_debug;
#endif
/* "%code requires" blocks.  */
#line 53 "bison_parser.y"

// %code requires block
#ifdef _MSC_VER
#define strdup _strdup
#endif

#include "../sql/Stat.h"
#include "../sql/statements.h"
#include "../SQLParserResult.h"
#include "parser_typedef.h"


// Auto update column and line number
#define YY_USER_ACTION \
		yylloc->first_line = yylloc->last_line; \
		yylloc->first_column = yylloc->last_column; \
		for(int i = 0; yytext[i] != '\0'; i++) { \
			yylloc->total_column++; \
			yylloc->string_length++; \
				if(yytext[i] == '\n') { \
						yylloc->last_line++; \
						yylloc->last_column = 0; \
				} \
				else { \
						yylloc->last_column++; \
				} \
		}

#line 86 "bison_parser.hpp"

/* Token kinds.  */
#ifndef MENT_TOKENTYPE
# define MENT_TOKENTYPE
  enum ment_tokentype
  {
    SQL_MENT_EMPTY = -2,
    SQL_YYEOF = 0,                 /* "end of file"  */
    SQL_MENT_error = 256,          /* error  */
    SQL_MENT_UNDEF = 257,          /* "invalid token"  */
    SQL_IDENTIFIER = 258,          /* IDENTIFIER  */
    SQL_STRING = 259,              /* STRING  */
    SQL_FLOATVAL = 260,            /* FLOATVAL  */
    SQL_INTVAL = 261,              /* INTVAL  */
    SQL_SQL_ILLEGAL = 262,         /* SQL_ILLEGAL  */
    SQL_DEALLOCATE = 263,          /* DEALLOCATE  */
    SQL_PARAMETERS = 264,          /* PARAMETERS  */
    SQL_INTERSECT = 265,           /* INTERSECT  */
    SQL_TEMPORARY = 266,           /* TEMPORARY  */
    SQL_TIMESTAMP = 267,           /* TIMESTAMP  */
    SQL_DISTINCT = 268,            /* DISTINCT  */
    SQL_NVARCHAR = 269,            /* NVARCHAR  */
    SQL_RESTRICT = 270,            /* RESTRICT  */
    SQL_TRUNCATE = 271,            /* TRUNCATE  */
    SQL_ANALYZE = 272,             /* ANALYZE  */
    SQL_BETWEEN = 273,             /* BETWEEN  */
    SQL_CASCADE = 274,             /* CASCADE  */
    SQL_COLUMNS = 275,             /* COLUMNS  */
    SQL_CONTROL = 276,             /* CONTROL  */
    SQL_DEFAULT = 277,             /* DEFAULT  */
    SQL_EXECUTE = 278,             /* EXECUTE  */
    SQL_EXPLAIN = 279,             /* EXPLAIN  */
    SQL_HISTORY = 280,             /* HISTORY  */
    SQL_INTEGER = 281,             /* INTEGER  */
    SQL_NATURAL = 282,             /* NATURAL  */
    SQL_PREPARE = 283,             /* PREPARE  */
    SQL_PRIMARY = 284,             /* PRIMARY  */
    SQL_SCHEMAS = 285,             /* SCHEMAS  */
    SQL_SPATIAL = 286,             /* SPATIAL  */
    SQL_VARCHAR = 287,             /* VARCHAR  */
    SQL_VIRTUAL = 288,             /* VIRTUAL  */
    SQL_BEFORE = 289,              /* BEFORE  */
    SQL_COLUMN = 290,              /* COLUMN  */
    SQL_CREATE = 291,              /* CREATE  */
    SQL_DELETE = 292,              /* DELETE  */
    SQL_DIRECT = 293,              /* DIRECT  */
    SQL_DOUBLE = 294,              /* DOUBLE  */
    SQL_ESCAPE = 295,              /* ESCAPE  */
    SQL_EXCEPT = 296,              /* EXCEPT  */
    SQL_EXISTS = 297,              /* EXISTS  */
    SQL_EXTRACT = 298,             /* EXTRACT  */
    SQL_GLOBAL = 299,              /* GLOBAL  */
    SQL_HAVING = 300,              /* HAVING  */
    SQL_IMPORT = 301,              /* IMPORT  */
    SQL_INSERT = 302,              /* INSERT  */
    SQL_ISNULL = 303,              /* ISNULL  */
    SQL_OFFSET = 304,              /* OFFSET  */
    SQL_RENAME = 305,              /* RENAME  */
    SQL_SCHEMA = 306,              /* SCHEMA  */
    SQL_SELECT = 307,              /* SELECT  */
    SQL_SORTED = 308,              /* SORTED  */
    SQL_TABLES = 309,              /* TABLES  */
    SQL_UNIQUE = 310,              /* UNIQUE  */
    SQL_UNLOAD = 311,              /* UNLOAD  */
    SQL_UPDATE = 312,              /* UPDATE  */
    SQL_VALUES = 313,              /* VALUES  */
    SQL_AFTER = 314,               /* AFTER  */
    SQL_ALTER = 315,               /* ALTER  */
    SQL_CROSS = 316,               /* CROSS  */
    SQL_DELTA = 317,               /* DELTA  */
    SQL_FLOAT = 318,               /* FLOAT  */
    SQL_GROUP = 319,               /* GROUP  */
    SQL_INDEX = 320,               /* INDEX  */
    SQL_INNER = 321,               /* INNER  */
    SQL_LIMIT = 322,               /* LIMIT  */
    SQL_LOCAL = 323,               /* LOCAL  */
    SQL_MERGE = 324,               /* MERGE  */
    SQL_MINUS = 325,               /* MINUS  */
    SQL_ORDER = 326,               /* ORDER  */
    SQL_OUTER = 327,               /* OUTER  */
    SQL_RIGHT = 328,               /* RIGHT  */
    SQL_TABLE = 329,               /* TABLE  */
    SQL_UNION = 330,               /* UNION  */
    SQL_USING = 331,               /* USING  */
    SQL_WHERE = 332,               /* WHERE  */
    SQL_CALL = 333,                /* CALL  */
    SQL_CASE = 334,                /* CASE  */
    SQL_CHAR = 335,                /* CHAR  */
    SQL_DATE = 336,                /* DATE  */
    SQL_DESC = 337,                /* DESC  */
    SQL_DROP = 338,                /* DROP  */
    SQL_ELSE = 339,                /* ELSE  */
    SQL_FILE = 340,                /* FILE  */
    SQL_FROM = 341,                /* FROM  */
    SQL_FULL = 342,                /* FULL  */
    SQL_HASH = 343,                /* HASH  */
    SQL_HINT = 344,                /* HINT  */
    SQL_INTO = 345,                /* INTO  */
    SQL_JOIN = 346,                /* JOIN  */
    SQL_LEFT = 347,                /* LEFT  */
    SQL_LIKE = 348,                /* LIKE  */
    SQL_LOAD = 349,                /* LOAD  */
    SQL_LONG = 350,                /* LONG  */
    SQL_NULL = 351,                /* NULL  */
    SQL_PLAN = 352,                /* PLAN  */
    SQL_SHOW = 353,                /* SHOW  */
    SQL_TEXT = 354,                /* TEXT  */
    SQL_THEN = 355,                /* THEN  */
    SQL_TIME = 356,                /* TIME  */
    SQL_VIEW = 357,                /* VIEW  */
    SQL_WHEN = 358,                /* WHEN  */
    SQL_WITH = 359,                /* WITH  */
    SQL_ADD = 360,                 /* ADD  */
    SQL_ALL = 361,                 /* ALL  */
    SQL_AND = 362,                 /* AND  */
    SQL_ASC = 363,                 /* ASC  */
    SQL_CSV = 364,                 /* CSV  */
    SQL_END = 365,                 /* END  */
    SQL_FOR = 366,                 /* FOR  */
    SQL_INT = 367,                 /* INT  */
    SQL_KEY = 368,                 /* KEY  */
    SQL_NOT = 369,                 /* NOT  */
    SQL_OFF = 370,                 /* OFF  */
    SQL_SET = 371,                 /* SET  */
    SQL_TBL = 372,                 /* TBL  */
    SQL_TOP = 373,                 /* TOP  */
    SQL_AS = 374,                  /* AS  */
    SQL_BY = 375,                  /* BY  */
    SQL_IF = 376,                  /* IF  */
    SQL_IN = 377,                  /* IN  */
    SQL_IS = 378,                  /* IS  */
    SQL_OF = 379,                  /* OF  */
    SQL_ON = 380,                  /* ON  */
    SQL_OR = 381,                  /* OR  */
    SQL_TO = 382,                  /* TO  */
    SQL_ARRAY = 383,               /* ARRAY  */
    SQL_CONCAT = 384,              /* CONCAT  */
    SQL_ILIKE = 385,               /* ILIKE  */
    SQL_SECOND = 386,              /* SECOND  */
    SQL_MINUTE = 387,              /* MINUTE  */
    SQL_HOUR = 388,                /* HOUR  */
    SQL_DAY = 389,                 /* DAY  */
    SQL_MONTH = 390,               /* MONTH  */
    SQL_YEAR = 391,                /* YEAR  */
    SQL_TRUE = 392,                /* TRUE  */
    SQL_FALSE = 393,               /* FALSE  */
    SQL_DATABASES = 394,           /* DATABASES  */
    SQL_USE = 395,                 /* USE  */
    SQL_EQUALS = 396,              /* EQUALS  */
    SQL_NOTEQUALS = 397,           /* NOTEQUALS  */
    SQL_LESS = 398,                /* LESS  */
    SQL_GREATER = 399,             /* GREATER  */
    SQL_LESSEQ = 400,              /* LESSEQ  */
    SQL_GREATEREQ = 401,           /* GREATEREQ  */
    SQL_NOTNULL = 402,             /* NOTNULL  */
    SQL_UMINUS = 403               /* UMINUS  */
  };
  typedef enum ment_tokentype ment_token_kind_t;
#endif

/* Value type.  */
#if ! defined MENT_STYPE && ! defined MENT_STYPE_IS_DECLARED
union MENT_STYPE
{
#line 119 "bison_parser.y"

	double fval;
	int64_t ival;
	char* sval;
	uintmax_t uval;
	bool bval;

	ment::SQLStatement* statement;
	ment::SelectStatement* 	select_stmt;
	ment::ImportStatement* 	import_stmt;
	ment::CreateStatement* 	create_stmt;
	ment::InsertStatement* 	insert_stmt;
	ment::DeleteStatement* 	delete_stmt;
	ment::UpdateStatement* 	update_stmt;
	ment::DropStatement*   	drop_stmt;
	ment::PrepareStatement* prep_stmt;
	ment::ExecuteStatement* exec_stmt;
	ment::ShowStatement*    show_stmt;
	ment::UseStatement* use_stmt;

	ment::TableName table_name;
	ment::TableRef* table;
	ment::Stat* stat;
	ment::OrderDescription* order;
	ment::OrderType order_type;
	ment::DatetimeField datetime_field;
	ment::LimitDescription* limit;
	ment::ColumnDefinition* column_t;
	ment::ColumnType column_type_t;
	ment::GroupByDescription* group_t;
	ment::UpdateClause* update_t;
	ment::Alias* alias_t;

	std::vector<ment::SQLStatement*>* stmt_vec;

	std::vector<char*>* str_vec;
	std::vector<ment::TableRef*>* table_vec;
	std::vector<ment::ColumnDefinition*>* column_vec;
	std::vector<ment::UpdateClause*>* update_vec;
	std::vector<ment::Stat*>* stat_vec;
	std::vector<ment::OrderDescription*>* order_vec;

#line 294 "bison_parser.hpp"

};
typedef union MENT_STYPE MENT_STYPE;
# define MENT_STYPE_IS_TRIVIAL 1
# define MENT_STYPE_IS_DECLARED 1
#endif

/* Location type.  */
#if ! defined MENT_LTYPE && ! defined MENT_LTYPE_IS_DECLARED
typedef struct MENT_LTYPE MENT_LTYPE;
struct MENT_LTYPE
{
  int first_line;
  int first_column;
  int last_line;
  int last_column;
};
# define MENT_LTYPE_IS_DECLARED 1
# define MENT_LTYPE_IS_TRIVIAL 1
#endif



int ment_parse (ment::SQLParserResult* result, yyscan_t scanner);
/* "%code provides" blocks.  */
#line 47 "bison_parser.y"

    const char* ment_token_to_string(int tok);
	extern int ment_char;

#line 325 "bison_parser.hpp"

#endif /* !YY_MENT_BISON_PARSER_HPP_INCLUDED  */
